home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / vsoup11.zip / newsrc.hh < prev    next >
C/C++ Source or Header  |  1996-08-01  |  3KB  |  82 lines

  1. //  $Id: newsrc.hh 1.5 1996/08/01 12:21:12 hardy Exp $
  2. //
  3. //  This progam/module was written by Hardy Griech based on ideas and
  4. //  pieces of code from Chin Huang (cthuang@io.org).  Bug reports should
  5. //  be submitted to rgriech@ibm.net.
  6. //
  7. //  This file is part of soup++ for OS/2.  Soup++ including this file
  8. //  is freeware.  There is no warranty of any kind implied.  The terms
  9. //  of the GNU Gernal Public Licence are valid for this piece of software.
  10. //
  11.  
  12.  
  13. #ifndef __NEWSRC_HH__
  14. #define __NEWSRC_HH__
  15.  
  16.  
  17. #include <stdio.h>
  18. #include "mts.hh"
  19.  
  20.  
  21. class TNewsrc {
  22. private:
  23.     //
  24.     //  article number range in the .newsrc file
  25.     //
  26.     typedef struct aRange {
  27.     struct aRange *next;    // pointer to next
  28.     long lo, hi;        // article number range */
  29.     } Range;
  30.  
  31.     //
  32.     //  newsgroup entry in the .newsrc file
  33.     //
  34.     typedef struct aGroup {
  35.     struct aGroup *next;        // pointer to next
  36.     struct aGroup *hashNext;        // pointer to next in hash list
  37.     const char *name;        // newsgroup name
  38.     Range *readList;        // list of read article ranges
  39.     char subscribed;        // subscribed flag
  40.     } Group, *pGroup;
  41.  
  42.     int fileChanged;                    // (internal) file has been changed (-> rewrite file)
  43.     pGroup groups;                      // list of .newsrc entries.
  44.     const char *filename;               // name of newsrc-file
  45.     TSemaphor sema;
  46.     const char *cacheGroupName;         // Cache for active group
  47.     pGroup cacheGroup;                  //          "
  48.     int fileRead;
  49.     pGroup addGroupP;
  50.  
  51.     const int hashSize = 1023;
  52.     pGroup hashTab[hashSize];
  53.     
  54. public:
  55.     TNewsrc( void );
  56.     ~TNewsrc();
  57.     TNewsrc( const TNewsrc &right );    // copy constructor not allowed !
  58.     operator = (const TNewsrc &right);  // assignment operator not allowed !
  59.  
  60.     int   readFile( const char *newsrcFile );
  61.     int   writeFile( void );
  62.     const char *grpFirst( void );
  63.     const char *grpNext( const char *prevGroupName );
  64.     int   grpSubscribed( const char *groupName );
  65.     int   grpExists( const char *groupName );
  66.     void  grpUnsubscribe( const char *groupName );
  67.     void  grpFixReadList( const char *groupName, long groupLo, long groupHi );
  68.     long  grpFirstUnread( const char *groupName, long groupLo );
  69.     int   artIsRead( const char *groupName, long artNum );
  70.     void  artMarkRead( const char *groupName, long artNum );
  71.     void  grpCatchup( const char *groupName, long groupLo, long groupHi );
  72.     void  *grpAdd( const char *groupName, int subscribe=0 );
  73.  
  74. private:
  75.     Range *getReadList( FILE *nrcFile );
  76.     void putReadList( FILE *fd, Range *head );
  77.     pGroup getGroupP( const char *groupName );
  78. };
  79.  
  80.  
  81. #endif   // __NEWSRC_HH__
  82.